/**
 * Description:
 * Class Name:MethodRefer
 * Date:2022/2/12 12:44
 *
 * @author LTisme
 * @version JAVA17
 */
package 疯狂Java讲义.第6章_面向对象_下._6_8_Java11增强的lambda表达式._6_8_4_方法引用与构造器引用;

import javax.swing.*;

@FunctionalInterface                // 这个是要求编译器严格检查这个是不是函数式接口
interface Converter{
    Integer convert(String from);
}

@FunctionalInterface
interface MyTest{
    String test(String a, int b, int c);
}

@FunctionalInterface
interface YourTest{
    JFrame win(String title);
}

public class MethodRefer {
    public static void main(String[] args) {
        Converter converter1 = from -> Integer.valueOf(from);
        Converter converter1_1 = Integer::valueOf;

        // 下面使用Lambda表达式常见Converter对象
        Converter converter2 = from -> "fkit.org".indexOf(from);
        Converter converter2_1 = "fkit.org"::indexOf;

        // 下面代码使用Lambda表达式创建MyTest对象
        MyTest mt = ((a, b, c) -> a.substring(b, c));
        MyTest mt_1 = String::substring;

        // 下面代码使用Lambda表达式创建YourTest对象
        YourTest yt = a -> new JFrame(a);
        YourTest yt_1 = JFrame::new;
    }
}
